import { useReactive } from "ahooks";
import { useModel } from "umi";
import { useEffect } from "react";
import compress from "gql-compress";

const useAllCategoryCommodities = () => {
    const { graphqlFetch } = useModel("global");

    const state = useReactive({
        categoryCommoditiesLoading: false,
        categoryCommodities: [],
    });

    // 加载所有部门信息, 用树的数据格式
    const loadCategoryCommodities = async ({ selectedClass }) => {
        state.categoryCommoditiesLoading = true;
        // let res = await graphqlFetch({
        //     query,
        //     variables: {},
        // });
        // let categoryCommodities = res?.a?.nodes || [];
        let categoryCommodities = [0, 1, 3, 3, 3, 3, 3]
        state.categoryCommodities = categoryCommodities;
        state.categoryCommoditiesLoading = false;
        return categoryCommodities;
    };


    return { ...state, loadCategoryCommodities };
};

const query = compress(``);

export default useAllCategoryCommodities;
